import { defineStore } from 'pinia'

const useSettingStore = defineStore('settingStore', {
    state() {
        return {
            fold: false, //用户控制菜单折叠还是收起控制
            refsh: false, //仓库这个属性用于控制刷新效果
        }
    }
})

interface UserInfo {
    userName: string;
    password: string;
    token: string;
}

//创建用户小仓库
const useUserStore = defineStore('UserInfo', {
    state: () => {
        return {
            userName: '游客', //sessionStorage.getItem('user'),
            password: '',
            token: '',
        }
    },
    actions: {
        setUserInfo(user: UserInfo) {
            this.$patch(user);
            sessionStorage.setItem('token', user.token);
            sessionStorage.setItem('user', user.userName);
        }
    }
})

export { useSettingStore, useUserStore }